package com.hefeng.controller;



import com.hefeng.domain.WxResidence;
import com.hefeng.service.IWxResidenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hefeng.common.log.annotation.Log;
import com.hefeng.common.log.enums.BusinessType;
import com.hefeng.common.security.annotation.RequiresPermissions;
import com.hefeng.common.core.web.controller.BaseController;
import com.hefeng.common.core.web.domain.AjaxResult;
import com.hefeng.common.core.web.page.TableDataInfo;
import java.util.List;

/**
 * 小区Controller
 *
 * @author ruoyi
 * @date 2022-09-15
 */
@Transactional
@RestController
@RequestMapping("/residence")
public class WxResidenceController extends BaseController
{
    @Autowired
    private IWxResidenceService wxResidenceService;

    /**
     * 查询小区列表
     */
    @RequiresPermissions("system:residence:list")
    @GetMapping("/list")
    public TableDataInfo list(WxResidence wxResidence)
    {
        startPage();
        List<WxResidence> list = wxResidenceService.selectWxResidenceList(wxResidence);
        return getDataTable(list);
    }



    /**
     * 获取小区详细信息
     */
    @RequiresPermissions("system:residence:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(wxResidenceService.selectWxResidenceById(id));
    }

    /**
     * 新增小区
     */
    @RequiresPermissions("system:residence:add")
    @Log(title = "小区", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxResidence wxResidence)
    {
        return toAjax(wxResidenceService.insertWxResidence(wxResidence));
    }

    /**
     * 修改小区
     */
    @RequiresPermissions("system:residence:edit")
    @Log(title = "小区", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxResidence wxResidence)
    {
        return toAjax(wxResidenceService.updateWxResidence(wxResidence));
    }

    /**
     * 删除小区
     */
    @RequiresPermissions("system:residence:remove")
    @Log(title = "小区", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(wxResidenceService.deleteWxResidenceByIds(ids));
    }
}